import os
import platform
import sys
import numpy as np


# 11归一化函数
def clean_normal(input_file, regression_type):
    """

    :param input_file:输入文件地址
    :param regression_type: 回归类型0: MaxMinNormalization, 1: Z_ScoreNormalization, 2:sigmoid
    :return: 数组格式输出数据
    """
    dict_type = {0: "MaxMinNormalization", 1: "Z_ScoreNormalization", 2: "sigmoid"}
    regression_type = int(regression_type)
    with open(input_file) as file_obj:
        array = eval(file_obj.read())
        # 处理数据
        after = []
        if regression_type == 0:
            max = np.max(array)
            min = np.min(array)
            for i in array:
                x = (i - min) / (max - min)
                after.append(x)
        if regression_type == 1:
            mu = np.average(array)
            sigma = np.std(array)
            for i in array:
                x = (i - mu) / sigma
                after.append(x)
        if regression_type == 2:
            k = np.ceil(np.log10(np.max(abs(np.array(array)))))
            after_array = np.array(array) / (10 ** k)
            after = list(after_array)

        return after


if __name__ == '__main__':
    print(clean_normal(sys.argv[1], sys.argv[2]))
